package com.zzw.controller;

import com.zzw.bean.Agent;
import com.zzw.bean.Msg;
import com.zzw.bean.ShareRadio;
import com.zzw.service.AgentService;
import com.zzw.service.ShareRadioService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 分润接口
 * @author 赵志伟
 * @version 1.0
 */
@SuppressWarnings({"all"})
@Controller
@RequestMapping("/shareRadio")
public class ShareRadioController {

    @Resource
    private ShareRadioService shareRadioService;

    @GetMapping(value = "/selectShareRadioByAgentId")
    @ResponseBody
    public Msg selectShareRadioByAgentId(@RequestParam("agentId") Integer agentId) {
        List<ShareRadio> shareRadios = shareRadioService.selectShareRadioByAgentId(agentId);
        return Msg.success().add("shareRadios", shareRadios);
    }

    @GetMapping(value = "/selectShareRadioByParentId")
    @ResponseBody
    public Msg selectShareRadioByParentId(@RequestParam("parentId") Integer parentId) {
        List<ShareRadio> shareRadios = shareRadioService.selectShareRadioByParentId(parentId);
        return Msg.success().add("shareRadios", shareRadios);
    }

    @PostMapping(value = "/insertShareRadio")
    @ResponseBody
    public Msg insertShareRadio(@RequestBody ShareRadio shareRadio) {
        int result = shareRadioService.insertShareRadio(shareRadio);
        return Msg.success().add("result", result);
    }

    @PostMapping(value = "/updateShareRadioStatus")
    @ResponseBody
    public Msg updateShareRadioStatus(@RequestBody ShareRadio shareRadio) {
        int result = shareRadioService.updateShareRadioStatus(shareRadio);
        return Msg.success().add("result", result);
    }
}
